Skip to content

Conversation

@mrmarcosmagalhaes
Copy link

@mrmarcosmagalhaes mrmarcosmagalhaes commented Jul 16, 2025

Closes #1500

QUALITY CHECKLIST

@bkoelman bkoelman changed the base branch from request-meta-tests-boilerplate to master July 19, 2025 09:08
@bkoelman
Copy link
Member

Thanks, this looks great!

I've changed the base of this PR, so that status checks run.

@codecov
Copy link

codecov bot commented Jul 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.25%. Comparing base (ae82a95) to head (2cb2e37).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1746   +/-   ##
=======================================
  Coverage   92.24%   92.25%           
=======================================
  Files         437      437           
  Lines       14860    14860           
  Branches     2451     2451           
=======================================
+ Hits        13708    13709    +1     
+ Misses        709      708    -1     
  Partials      443      443           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bkoelman
Copy link
Member

bkoelman commented Dec 3, 2025

@mrmarcosmagalhaes, do you still want to complete the work on this PR? If not, please let me know, so I can pick up from here.

@mrmarcosmagalhaes
Copy link
Author

mrmarcosmagalhaes commented Dec 8, 2025 via email

@bkoelman
Copy link
Member

bkoelman commented Dec 9, 2025

Congratulations! Looking forward to your contribution.

@mrmarcosmagalhaes
Copy link
Author

@bkoelman Completed and consolidated RequestMetaTests.
All resource, relationship, and atomic operations now have a single integration test per endpoint, covering all valid meta locations.
Added full coverage for atomic relationship operations (to-one and to-many), fully aligned with the JSON:API spec.
Sorry for the late push but my life right now is not easy.

@bkoelman
Copy link
Member

@mrmarcosmagalhaes Can you take a look at the build errors?

@mrmarcosmagalhaes
Copy link
Author

mrmarcosmagalhaes commented Jan 13, 2026 via email

Copy link
Member

@bkoelman bkoelman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all the feedback. Minus the comments posted here, I think RequestMetaTests is good to go. I've added a comment requesting to sync up the operations tests, which I'll take a closer look at next time.

Copy link
Member

@bkoelman bkoelman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left some more feedback. The tests for operations are not quite in sync yet.

}

[Fact]
public async Task Accepts_meta_in_remove_from_ToOne_relationship_request()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public async Task Accepts_meta_in_remove_from_ToOne_relationship_request()
public async Task Accepts_meta_in_remove_from_ToMany_relationship_request()

I don't understand why this was changed from to-many to to-one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name does not match the implementation. I’ve already reverted the test name and refactor de code.

await _testContext.RunOnDatabaseAsync(async dbContext =>
{
dbContext.ProductFamilies.Add(existingFamily);
existingTicket.ProductFamily = existingFamily;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to before the RunOnDatabaseAsync block, like this:

ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();

SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
existingTicket.ProductFamily = existingFamily;


store.Document.Meta.Should().BeEquivalentToJson(documentMeta);

store.Document.Data.Should().NotBeNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document.Data is a struct, so it can never be null. Therefore, this line is redundant.


store.Document.Meta.Should().BeEquivalentToJson(documentMeta);

store.Document.Data.Should().NotBeNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document.Data is a struct, so it can never be null. Therefore, this line is redundant.


store.Document.Should().NotBeNull();

store.Document.Data.SingleValue.Should().BeNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint updates a to-many relationship (data is an array). I don't think it makes sense to assert that data is not an object. So this assertion can be removed.

}

[Fact]
public async Task Accepts_meta_in_add_ToMany_relationship_request()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public async Task Accepts_meta_in_add_ToMany_relationship_request()
public async Task Accepts_meta_in_add_to_ToMany_relationship_request()

}

[Fact]
public async Task Accepts_meta_in_add_resource_request_with_ToMany_relationship_operation()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming pattern is not simply to add "_operation" to all existing names.

This is an operation that updates a resource, along with its to-many relationship. Therefore, the name should be: "Accepts_meta_in_add_resource_operation_with_ToMany_relationship". Please verify the other names within OperationsRequestMetaTests.cs for correctness.

Comment on lines +419 to +421
SupportTicket existingTicket1 = _fakers.SupportTicket.GenerateOne();
SupportTicket existingTicket2 = _fakers.SupportTicket.GenerateOne();
ProductFamily existingFamily = _fakers.ProductFamily.GenerateOne();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existingFamily should come first (as it does in the operations equivalent), because that's where the scenario starts (see the request URL).

Applies to multiple tests.

}

[Fact]
public async Task Accepts_meta_in_remove_from_ToOne_relationship_operation()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is about to-many.

}

[Fact]
public async Task Accepts_meta_in_atomic_remove_resource_operation()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public async Task Accepts_meta_in_atomic_remove_resource_operation()
public async Task Accepts_meta_in_remove_resource_operation()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for submitting meta

2 participants